/*
    在对列进行离散化之后，使用线段树
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1005;

struct Line{
    LL x1,x2,y;
    int tag;
    Line(){}
    Line(LL x1_,LL x2_,LL y_,int tag_):x1{x1_},x2{x2_},y{y_},tag{tag_}{}
    bool operator<(const Line& line)const{
        return this->y<line.y;
    }
};
Line lines[2*N];
LL xs[2*N];
set<int> mys;
int n;
LL tree[8*N];
LL counts[8*N];

void push_up(int idx,int l,int r)
{
    if(counts[idx]>0){
        tree[idx] = xs[r]-xs[l];
    }
    else if(r==l+1){
        tree[idx] = 0;
    }
    else{
        tree[idx] = tree[2*idx]+tree[2*idx+1];
    }
}

void add(int idx,int l,int r,const LL L,const LL R,const int v){
    if(xs[l]>=R||xs[r]<=L) return;
    if(L<=xs[l]&&xs[r]<=R||r-l==1){
        counts[idx] += v;
        push_up(idx,l,r);
        return;
    }
    int mid = (r-l)/2+l;
    add(2*idx,  l,mid,L,R,v);
    add(2*idx+1,mid,r,L,R,v);
    push_up(idx,l,r);
}

LL x1,x2,y11,y2;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld%lld%lld",&x1,&y11,&x2,&y2);
        lines[i] = Line(x1,x2,y11,-1);
        lines[i+n] = Line(x1,x2,y2,1);
        mys.insert(x1); mys.insert(x2);
    }
    sort(lines+1,lines+2*n+1);

    int u=1;
    for(auto p=mys.begin();p!=mys.end();p++) {
        xs[u] = *p;
        u++;
    }

    LL ans = 0;
    int counts[2*N];
    memset(counts,0,sizeof(counts));
    for(int i=1;i<2*n;i++){
        add(1,1,u-1,lines[i].x1,lines[i].x2,lines[i].tag);
        ans += tree[1]*(lines[i+1].y-lines[i].y);
    }
    printf("%lld\n",ans);
    return 0;
}

/*
4
1 10 15 8
1 6 14 3
2 9 5 1
11 15 13 5
*/